#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
ComfyUI 整合下载器插件
"""

import sys
from pathlib import Path

# 导入统一的环境配置
from public.env_setup import setup_environment, ENV_CONFIG

# 使用统一的环境配置
ENV_CONFIG = setup_environment()

class IntegratedDownloader:
    """整合下载器插件类"""
    order = 5
    
    def start(self) -> bool:
        """启动整合下载器"""
        print("0. 退出")
        print("1. 从README.md下载模型")
        print("2. 下载MIT-HAN-LAB模型")
        print("3. 安装nunchaku")
        print("4. 自定义HuggingFace下载")
        print("5. 安装insightface")
        print("6. 下载ReActor模型")
        
        choice = input("选择功能 (0-6): ").strip()
        if choice == "0" or choice.lower() == "q":
            print("已退出插件。"); return True
        elif choice == "1":
            from plugins.ipadapter import ipadapter_down
            ipadapter_down.main()
        elif choice == "2":
            from plugins.Nunchaku import download_hf_models
            download_hf_models.main()
        elif choice == "3":
            from plugins.Nunchaku import install_nunchaku
            install_nunchaku.main()
        elif choice == "4":
            from hf_down_plugin import HFDownloader
            downloader = HFDownloader()
            downloader.start()
        elif choice == "5":
            from plugins.ReActor import install_insightface
            install_insightface.main()
        elif choice == "6":
            from plugins.ReActor import download_models
            download_models.main()
        
        return True
    
    @staticmethod
    def Launch(self):
        downloader = IntegratedDownloader()
        return downloader.start()

def main():
    downloader = IntegratedDownloader()
    downloader.start()

if __name__ == "__main__":
    main() 